package demo516;

import demo516.Emp;
import demo516.TextList;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Demo {
    public static void main(String[] args) {
        System.out.println("欢迎来到员工管理系统！");
        System.out.println("请选择你需要进行的操作：");
        System.out.println("1.添加员工信息");
        System.out.println("2.查询所有员工信息");
        System.out.println("3.根据员工姓名查询员工信息");
        System.out.println("4.删除指定员工信息");
        System.out.println("5.根据员工编号查询员工信息");
        System.out.println("6.更新员工信息");


        Emp emp1 = new Emp("1001", "武则天", 30);
        Emp emp2 = new Emp("1002", "李白", 25);
        Emp emp3 = new Emp("1003", "小乔", 21);

        TextList textList = new TextList();
        List<Emp> list = new ArrayList();
//        1.添加员工信息
        textList.addEmp(list,emp1);
        textList.addEmp(list,emp2);
        textList.addEmp(list,emp3);
        System.out.println(list);
//        2.查询所有员工信息
        textList.findAllEmp(list);
//        3.查询指定员工信息
        System.out.println("请输入用户名：");
        Scanner sc = new Scanner(System.in);
        Emp emp = textList.findEmpName(list,sc.next());
        System.out.println(emp);
//        4.删除指定员工信息
        System.out.println("请输入员工编号：");
        String number = sc.next();
        textList.deleteEmpNumber(list,number);
//  5.先查询，再修改
        System.out.println("请输入需要查询的员工编号：");
        String findNumber = sc.next();
        Emp findEmp = textList.findEmpName(list,findNumber);
        System.out.println(findEmp);

//        6.更新员工信息
//        Emp setEmp = new Emp();
        System.out.println("请输入需要修改的员工编号：");
        String updateNumber = sc.next();
        Emp updateEmp = textList.findEmpName(list,updateNumber);
        System.out.println("请输入修改的员工年龄：");
        int updateAge = sc.nextInt();
        updateEmp.setAge(updateAge);
       textList.updateEmpAge(list,updateEmp);


    }
}
